package com.naiterui.ehp.bs.cms.modules.wms.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.naiterui.ehp.bs.cms.common.entity.BaseTree;
import com.naiterui.ehp.bs.cms.modules.wms.entity.Category;
import com.naiterui.ehp.bs.cms.modules.wms.mapper.CategoryMapper;
import com.naiterui.ehp.bs.cms.modules.wms.service.ICategoryService;
import com.naiterui.ehp.bs.cms.modules.wms.vo.CategoryVO;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> implements ICategoryService {
    @Override
    public List<Category> queryList() {
        List<Category> list = this.list();
        return BaseTree.listToTree(list);
    }

    @Override
    public List<CategoryVO> getCategory() {
        List<Category> list = this.list();
        return list.stream().map(p -> CategoryVO.builder().id(p.getId()).name(p.getName()).build()).collect(Collectors.toList());
    }
}
